<template>
  <div>
    <Backnav backTitle="编辑收获地址"></Backnav>
    <van-address-edit
      :area-list="areaList"
      show-postal
      :address-info="AddressInfo"
      show-set-default
      :tel-validator="validator"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
    />
  </div>
</template>

<script>
import Backnav from "../../components/nav/Backnav";
import { areaList } from "@vant/area-data";
// import { Toast } from "vant";

export default {
  name: "Addaddre",
  components: { Backnav },
  data() {
    return {
      areaList,
      AddressInfo: {
        id: "1",
        name: "黄龙万科中心",
        tel: "15866666666",
        province: "北京市",
        city: "北京市",
        county: "东城区",
        addressDetail: "杭州市西湖区",
        postalCode: "635112",
        isDefault: true,
        // areaCode: "",
      },
    };
  },
  methods: {
    onSave() {
      Toast("save");
    },
    //获取手机号
    validator(e) {
      console.log(e);
      let myreg1 = /^[1][3,4,5,7,8][0-9]{9}$/;
      let myreg2 = /^[2][3,4,5,7,8][0-9]{6}$/;
      if (!myreg1.test(e) && !myreg2.test(e)) {
        console.log("手机号错误");
        return false;
      } else {
        console.log("手机号正确");
        return true;
      }
    },
  },
};
</script>

<style>
.van-button {
  background-color: #4bd863;
  border: 0;
  margin-top: 210px;
}
.btn {
  width: 85%;
  height: 35px;
  /* margin-top: 200px; */
  bottom: 50px;
  position: fixed;
  margin-left: 28px;
  background-color: #4bd863;
}
</style>